<template>
  <div class="myteacher">
    <NavBar title="关注的老师" left-arrow @click-left="onClickLeft" />
    <div class="star_teacher">
      <div v-for="(item,index) in list" :key="index" @click="getTeach(item)">
        <div>
          <img :src="item.avatar" alt />
        </div>
        <div>
          <p>
            {{item.teacher_name}}
            <span style="color:orange">{{item.level_name}}</span>
          </p>
          <p class="ptext">{{item.introduction}}</p>
        </div>
        <div>
          <button class="btn" @click="delCom(item.teacher_id)">取消关注</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { NavBar } from "vant";
import { getLikeList, teachgoCom } from "../../https/https";
export default {
  components: {
    NavBar,
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
    getTeach(item) {
      console.log(item);
    },
    delCom(id) {
      teachgoCom(id).then((res) => {
        console.log(res);
      });
      getLikeList({
        page: 1,
        limit: 10,
        type: 2,
      }).then((res) => {
        console.log(res);
        this.list = res.list;
      });
    },
  },
  data() {
    return {
      list: [],
    };
  },
  mounted() {
    getLikeList({
      page: 1,
      limit: 10,
      type: 2,
    }).then((res) => {
      console.log(res);
      this.list = res.list;
    });
  },
};
</script>

<style scoped>
.myteacher {
  background-color: #eeeeee;
  padding-bottom: 100px;
}
.star_teacher > div {
  width: 90%;
  height: 80px;
  margin: 10px auto;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  font-size: 14px;
  background-color: #ffffff;
  padding-left: 10px;
  border-radius: 15px;
}
.star_teacher > div > div > img {
  width: 50px;
  height: 50px;
  border-radius: 50%;
}
.star_teacher > div > div > p {
  margin-left: 15px;
  margin-bottom: 10px;
}
.ptext {
  width: 200px;
  color: #999;
  font-size: 12px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.btn {
  padding: 5px;
  border-radius: 10px;
  background-color: rgb(241, 213, 189);
  border: 1px solid rgb(241, 213, 189);
  color: orange;
}
</style>